0.2 - URL is now shown in the Browser/GetNET requester (only if he parsed
URL doesn't contain a doublequote).
- Added Index to locate the presence of the arexx port
of a browser.
- Added SCREENTOFRONT and RELOAD for AWeb.
- Removed loading of rexxsupport.library, it's not needed.
- Forgot to call the Thor ARexx port before calling REQUESTNOTIFY.
0.3 - Fixed the non working AMosaic part.
- Added Voyager support.
- Start browser when needed.
- Start TCP/IP stack when needed (optionally, AWebII 2.1+ only).
- Optionally save the url (IBrowse 1.02+ only).
- Distributed on IRC only.
0.4 - Changed the way the auto url save thingy for IBrowse works.
It now waits until the title isn't '(Untitled)' or after the
timeout period has passed.
Thanks to Shaun Downend for helping to fix this.
0.5 - Forgot to start the TCP/IP stack if a browser wasn't running yet.
- Changed the requester text when a browser would fain to start.
- Now Checking for a browser presence before the first requester
pops up, saving one requester when the browser isn't found.
- Will ask what to do when the page title returned is 'IBrowse Error',
'Proxy Message' or '(Untitled)'. (IBrowse only)
0.6 - Added Retry button to the requester that pops up if IBrowse is unable
grab the page title within the timeout. Retry will grab the current
tilte and save the url with that title (much like the add button in
IBrowse itself).
0.7 - Added external config handling stuff.
- Changed the Voyager ARexx port from MINDWALKER to VOYAGER. This change
means that only Voyager 2.0+ will be supported
0.8 - Removed old config things.
- Added option to start cfgHTTP when no config is found.
- Removed ~ in the check_tcp.
0.9 - Fixed a problem with certain URL's that were not passed correctly
to the browsers. The URL's are now passed to the browser in double
quotes. This has only been tested with Ibrowse.
~!
*/
/*!~ "Variables" */
cfgpath = 'env:thor/'
cfgfile = 'http.config'
CALL OPEN(tmp, 'env:thor/thorpath')
thorpath = readln(tmp)
CALL CLOSE(tmp)
/*~!*/
/*!~ "Init" */
OPTIONS RESULTS
OPTIONS FAILAT 31
/*TRACE RESULTS*/
p=' '||ADDRESS()||' '||SHOW('P',,)
IF POS(' THOR.',p)>0 THEN thorport=WORD(SUBSTR(p,POS(' THOR.',p)+1),1)
ELSE DO
SAY 'THOR port not found!'
EXIT 10
END
IF ~SHOW('p', 'BBSREAD') THEN DO
ADDRESS COMMAND
"run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
"WaitForPort BBSREAD"
END
IF ~SHOW('L','rexxsupport.library') THEN CALL ADDLIB('rexxsupport.library',0,-30,0)
IF ~SHOW('L','rexxsupport.library') THEN DO
'REQUESTNOTIFY TEXT "Couldn''t open rexxsupport.library" BT "_Ok"'
EXIT
END
/*~!*/
/*!~ "Main"*/
PARSE ARG url
CALL loadprefs
ADDRESS(thorport)
CALL check_browser
reqtxt = url'\n\nWhat do you want to do with the URL?\n · Send URL to WWW Browser\n · Save the URL using GetNET'
IF browser_port THEN buttons = '_Browser|_GetNET|_Quit'
ELSE buttons = '_Start Browser|_GetNET|_Quit'
'REQUESTNOTIFY TEXT "'reqtxt'" BT "'buttons'"'
answer = RESULT
IF browser_port THEN DO
SELECT
WHEN answer = 1 THEN DO
CALL check_tcp
CALL send_browser
END
WHEN answer = 2 THEN CALL send_getnet
OTHERWISE EXIT
END
END
ELSE DO
SELECT
WHEN answer = 1 THEN DO
CALL check_tcp
CALL start_browser
END
WHEN answer = 2 THEN CALL send_getnet
OTHERWISE EXIT
END
END
EXIT
/*~!*/
/*!~ "LoadPrefs" */
loadprefs:
IF ~EXISTS(cfgpath||cfgfile) THEN DO
Address(thorport)
'Requestnotify TEXT "Could not find the configuration file.\nRun CfgHTTP to create one or quit." BT "_CfgHTTP|_Quit"'
IF RC = 0 THEN DO
IF RESULT = 0 THEN EXIT
IF RESULT = 1 THEN ADDRESS COMMAND 'rx' thorpath'rexx/cfghttp.thor'
END
EXIT
END
ELSE DO
CALL OPEN(prf,cfgpath||cfgfile,'R')
DO UNTIL EOF(prf)
line = READLN(prf)
SELECT
WHEN UPPER(WORD(line,1)) = 'GETNET' THEN DO
getnet = SUBWORD(line,2)
END
WHEN UPPER(WORD(line,1)) = 'BROWSER' THEN DO
browser = WORD(line,2)
END
WHEN UPPER(WORD(line,1)) = 'BROWSEREXE' THEN DO
browserexe = SUBWORD(line,2)
END
WHEN UPPER(WORD(line,1)) = 'SAVE_URL' THEN DO
save_url = WORD(line,2)
END
WHEN UPPER(WORD(line,1)) = 'SAVEDELAY' THEN DO
savedelay = WORD(line,2)
END
WHEN UPPER(WORD(line,1)) = 'AWEB_TCP' THEN DO
aweb_tcp = WORD(line,2)
END
WHEN UPPER(WORD(line,1)) = 'TCP_IP' THEN DO
tcp_ip = SUBWORD(line,2)
END
OTHERWISE NOP
END
END
CALL CLOSE(prf)
CALL checkprefs
END
RETURN
/*~!*/
/*!~ "CheckPrefs" */
checkprefs:
IF getnet = '' THEN CALL prefserror('GETNET')
IF ~DATATYPE(browser, 'NUM') THEN CALL prefserror('BROWSER')
IF browserexe = '' THEN CALL prefserror('BROWSEREXE')
IF ~DATATYPE(save_url, 'BIN') THEN CALL prefserror('SAVE_URL')
IF ~DATATYPE(savedelay, 'NUM') THEN CALL prefserror('SAVEDELAY')
IF ~DATATYPE(aweb_tcp, 'BIN') THEN CALL prefserror('AWEB_TCP')
IF tcp_ip = '' THEN tcp_ip = 'RequestChoice >NIL: TITLE="HTTP ERROR" BODY="No TCP/IP stack to run. Use CfgHTTP to edit." GADGETS="OK" Pubscreen=Thor.1'
RETURN
/*~!*/
/*!~ "PrefsError" */
prefserror:
prferr = ARG(1)
ADDRESS(thorport)
'REQUESTNOTIFY TEXT "The config file is not in the\ncorrect format. An error occured at\nor before 'prferr'.\nPlease run CfgHTTP to correct this.\n\nIf the problem remains, contact\nthe author at rvhooff@caiw.nl" BT "_OK"'
EXIT
RETURN
/*~!*/
/*!~ "Check for Browser" */
check_browser:
SELECT
WHEN INDEX(SHOW('P'),'IBROWSE') > 0 THEN DO
browser_port = 1
RETURN
END
WHEN INDEX(SHOW('P'),'AWEB.1') > 0 THEN DO
browser_port = 1
RETURN
END
WHEN INDEX(SHOW('P'),'AMOSAIC.1') > 0 THEN DO
browser_port = 1
RETURN
END
WHEN INDEX(SHOW('P'),'VOYAGER') > 0 THEN DO
browser_port = 1
RETURN
END
OTHERWISE browser_port = 0
END
RETURN
/*~!*/
/*!~ "Check for TCP/IP"*/
check_tcp:
IF (aweb_tcp & browser = 2) THEN RETURN
ELSE DO
IF ~SHOWLIST('L','bsdsocket.library') THEN DO
ADDRESS COMMAND tcp_ip
IF SHOWLIST('L','bsdsocket.library') THEN CALL send_browser
ELSE DO
'REQUESTNOTIFY TEXT "No TCP/IP stack found.n\nCan''t connect to the URL." BT "_OK"'
END
END
END
RETURN
/*~!*/
/*!~ "Send to Browser" */
send_browser:
SELECT
WHEN INDEX(SHOW('P'),'IBROWSE') > 0 THEN DO
ADDRESS 'IBROWSE'
'QUERY TITLE'
oldpagetitle = RESULT
'GOTOURL "'url'"'
IF save_url THEN DO
timeout = TIME('S')
DO FOREVER
'QUERY TITLE'
pagetitle = RESULT
IF (pagetitle ~= '(Untitled)' & oldpagetitle ~= pagetitle) THEN LEAVE
IF TIME('S') >= timeout + savedelay THEN LEAVE
END
IF (pagetitle = 'IBrowse Error' | pagetitle = 'Proxy Message' | pagetitle = '(Untitled)') THEN DO
ADDRESS(thorport)
'THORTOFRONT'
reqbody = 'Unable to find the page title for:\n\n'url'\n\nYou have 4 options:\n · Change the title\n · Retry (grab the title now)\n · Clear it (save but no title)\n · Discard the URL and not save it'
'REQUESTSTRING TITLE "Title error" BODY "'reqbody'" BT "_OK|_Retry|_Clear|_Discard" ID "'pagetitle'"'
IF (RC = 30) THEN DO
'REQUESTNOTIFY TEXT "'THOR.LASTERROR'" BT "_Ok"'
EXIT
END
IF RC = 5 THEN EXIT
IF RC = 0 THEN DO
IF THORRC = 1 THEN pagetitle = RESULT
IF THORRC = 2 THEN DO
ADDRESS 'IBROWSE'
'QUERY TITLE'
pagetitle = RESULT
END
IF THORRC = 3 THEN pagetitle = ''
END
ADDRESS 'IBROWSE'
END
'ADDHOTLIST TITLE "'pagetitle'" LOCATION' url
END
EXIT
END
WHEN INDEX(SHOW('P'),'AWEB.1') > 0 THEN DO
ADDRESS 'AWEB.1'
'OPEN URL "'url'"' 'RELOAD'
'SCREENTOFRONT'
EXIT
END
WHEN INDEX(SHOW('P'),'AMOSAIC.1') > 0 THEN DO
ADDRESS 'AMOSAIC.1'
'JUMP URL "'url'"'
EXIT
END
WHEN INDEX(SHOW('P'),'VOYAGER') > 0 THEN DO
ADDRESS 'VOYAGER'
'OPENURL URL "'url'"'
EXIT
END
OTHERWISE DO
'REQUESTNOTIFY TEXT "Browser not found, either your path\nto the browser is incorrect or there\nis another reason your browser is\nunable to start." BT "_OK"'
EXIT
END
END
RETURN
/*~!*/
/*!~ "Start Browser"*/
start_browser:
ADDRESS COMMAND 'run >nil:' browserexe
SELECT
WHEN browser = 1 THEN port = 'IBROWSE'
WHEN browser = 2 THEN port = 'AWEB.1'
WHEN browser = 3 THEN port = 'AMOSAIC.1'
WHEN browser = 4 THEN port = 'MINDWALKER'
OTHERWISE DO
'REQUESTNOTIFY TEXT "No running browser found." BT "_OK"'